package com.jh.concurrent.juc.cyclicbarrier;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

/**
 * @author JH_Wong
 * @projectName newforward
 * @title
 * @package com.jh.concurrent.juc.cyclicbarrier
 * @description
 * @date 2019-05-21 09:18
 */
public class DataImportThread extends Thread{

    private CyclicBarrier cyclicBarrier;
    private String path;

    public DataImportThread(CyclicBarrier cyclicBarrier, String path) {
        this.cyclicBarrier = cyclicBarrier;
        this.path = path;
    }

    @Override
    public void run() {
        try {
            System.out.println("开始导入文件：" + path + " --- begin");
            cyclicBarrier.await();
            System.out.println("开始导入文件：" + path + " --- end");
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (BrokenBarrierException e) {
            e.printStackTrace();
        }
    }
}
